package myStudent

import org.springframework.cloud.contract.spec.Contract

Contract.make {
    request {
        method 'GET'
        url value(consumer(regex('/api/v2/students/\\d+')),
                producer('/api/v2/students/1'))
    }
    response {
        status 200
        body("""
              {
                  "id": 1,
                  "userName": "11",
                  "email": "1@1.com",
                  "mobilePhone": "132456453423214564475"
              }
        """)
        bodyMatchers {
            jsonPath('$.id', byRegex(number()))
            jsonPath('$.userName', byRegex(nonEmpty()))
            jsonPath('$.email', byRegex(email()))
            jsonPath('$.mobilePhone',byRegex(nonEmpty()))
        }
        headers {
            contentType(applicationJsonUtf8())
        }
    }
}